#include "pch.h"
#include <string>
#include<fstream>
#include <vector>
#include <map>
#include <iostream>
#include <shlwapi.h>
#include "tinyxml2.h"
#include "XmlPara.h"
#include "CDialogXmlViewer.h"
ofstream out("dllxmlout.log");
using namespace std;
using namespace tinyxml2;
XML_DLL int parseXmlWithCompare(string fil_dirA, string fil_dirB,vector<string>& loadlist)
{
	cXmlParaDoc* vParaA = nullptr;
	cXmlParaDoc* vParaB = nullptr;
#ifdef DEBUG
	out << "fil_dirA " << fil_dirA << " fil_dirB " << fil_dirB << endl;
#endif
	try 
	{
		vParaA = new cXmlParaDoc(fil_dirA);
	}
	catch (std::exception &error)
	{
		out << "load A error " << error.what() << std::endl;
		if (vParaA)
		{
			delete vParaA;
		}
		return -1;
	}
	try
	{
		vParaB = new cXmlParaDoc(fil_dirB);
	}
	catch (std::exception& error)
	{
		out << "load B error " << error.what() << std::endl;
		if (vParaB)
		{
			delete vParaB;
		}
		return -2;
	}
	vParaA->BindChildCraft();
	vParaB->BindChildCraft();
#ifdef DEBUG
	out << "parse A---------------------------" << endl;
	vParaA->PrintValue();
	out << "parse B---------------------------" << endl;
	vParaB->PrintValue();
#endif
	CDialogXmlViewer xmlDlgViewer(nullptr, vParaA, vParaB,&loadlist);
	int iRet=xmlDlgViewer.DoModal();
	delete vParaA;
	vParaA = nullptr;
	delete vParaB;
	vParaB = nullptr;
	return iRet;
}